<?php //var_dump($this->buyProInfo);?><br>
<body class="app" data-ad="true">
<?php $CDN= $this->CommonHelper()->imageDomain();?>
<section class="app-content">
	<form id="orderForm" action="/order/createMall" method='post'>

	<section class="page page-index noline page-b" data-plugin-type="info_front">
        <div class="top-bar">提交定单<a href="<?php echo $this->url('organization', array('action'=>'index','id'=> $orgInfo['org_id']));?>" 
        class="btn-t-back"></a></div>

        <div class="info-list bw">
<!--             <a class="ico-arr ico-down" href="javascript:;"></a> -->
            <dl class="info-addr">
                <dt class="i-title"><b>收货地址</b></dt>
                <dd>单位(默认）</dd>
            </dl>
<!--             <dl class="info-addr hide"> -->
<!--                 <dt>&nbsp;</dt> -->
<!--                 <dd>地址xxxx1111</dd> -->
<!--             </dl> -->
<!--             <dl class="info-addr hide"> -->
<!--                 <dt>&nbsp;</dt> -->
<!--                 <dd>地址xxxx222</dd> -->
<!--             </dl> -->


            <dl><dt>详细地址</dt>
                <dd><input id="address_info" name="address_info"  type="text" placeholder="请填写"></dd>
            </dl>

            <dl>
                <dt class="i-title"><b>订餐人信息</b></dt>
                <dd>&nbsp;</dd>
            </dl>
            <dl><dt>姓名</dt>
                <dd><input id="receiver_name" name="receiver_name" type="text" placeholder="请填写（必填）"></dd>
            </dl>
            <dl><dt>联系方式</dt>
                <dd><input id="cellphone" name="cellphone" type="text" placeholder="请填写（必填）"></dd>
            </dl>
            <dl><dt>其他</dt>
                <dd><input id="receiver_mark" name="receiver_mark" type="text" placeholder="请填写"></dd>
            </dl>

            <dl>
                <dt class="i-title"><b>商家代金券</b></dt>
                <dd><select id="voucher_id" name="voucher_id">
                    <option value="">无</option>
                    <?php foreach ($this->voucherList as $voucher):?>
                    	<option value="<?php echo $voucher['id'];?>"><?php echo $voucher['vt_name'];?></option>
                    <?php endforeach;?>
<!--                     <option>xxx</option> -->
                </select></dd>
            </dl>
            <div class="shop-info">
                <span><img src="<?php echo $CDN.$this->orgInfo['org_logo'];?>"></span><b><?php echo $this->orgInfo['org_name'];?></b>
            </div>
        </div>

        <div class="info-list bw mt20 mb20">
            <table cellpadding="0" cellspacing="0">
                <tbody>
                    <?php foreach ($this->buyProInfo['list'] as $buyPro):?>
                    <tr>
                        <td class="t01"><?php echo $buyPro['product_name'];?></td>
                        <td class="t02">¥ <?php echo $buyPro['product_price'];?></td>
                        <td class="t03">×<?php echo $buyPro['num'];?></td>
                    </tr>
                    <?php endforeach;?>
                    <tr class="total-price">
                        <td class="t01">总计：</td>
                        <td class="t02" style="color: #ff5500;">¥ 5.00</td>
                        <td class="t03">x2</td>
                    </tr>
                    <tr class="total-price" id="voucher_dis">

                    </tr>
                    <tr class="total-express">
                        <td class="t01">邮  费</td>
                        <td class="t02" style="color: #ff5500;">¥ <?php echo $this->orgInfo['org_postage'];?></td>
                        <td class="t03"></td>
                    </tr>
                    <tr class="total-price">
                        <td class="t01">实 付</td>
                        <td class="t02" style="color: #ff5500;" id="totalPrice">¥ <?php echo $this->buyProInfo['totalPrice'];?></td>
                        <td class="t03"></td>
                    </tr>
                </tbody>

            </table>
            <div class="remark-line">
                <span>备注</span><input id="order_mark" name="order_mark" type="text" placeholder=" 可输入备注"><!-- <a href="javascript:;" class="btn-more-r"></a> -->
            </div>
        </div>

	</section>

    <div class="total-bar">
        <a class="btn-yel02 btn-statement" href="javascript:createOrder();">提交定单</a>
       <span class="t-num">待支付</span>
        <span class="t-price" id="t-price"> ¥<?php echo $this->buyProInfo['payPrice'];?>元</span>
        
    </div>   
        <input id="org_id" name="org_id" type="hidden" value="<?php echo $this->orgInfo['org_id'];?>">
        <input id="proJson" name="proJson" type="hidden" value="<?php echo $this->proJson;?>">
    </form>

</section>
<script type="text/javascript">
$(function () {
//详情展开按钮
//     $('.info-list .ico-down').click(function(){
//         if($(this).hasClass('ico-up')){
//             $(this).removeClass('ico-up').next('.info-addr').siblings('.info-addr').hide();
//         }else{
//             $(this).addClass('ico-up').next('.info-addr').siblings('.info-addr').show();
//         }
//     })
});

var voucher_list = <?php echo $this->voucherJson;?>;
var total_price = <?php echo $this->buyProInfo['totalPrice'];?>;

$(function () {
	$("#voucher_id").change(function(e){
		calTotalPrice($(this));
		return; 
    })

	if ($("#voucher_id").children().size() > 0) {
		$("#voucher_id").val($("#voucher_id").children().eq(1).val());
		calTotalPrice($("#voucher_id").children().eq(1));
	}
});

function calTotalPrice($item) {
	for(var key in voucher_list){
		if (voucher_list[key].id == $item.val()) {
			$("#totalPrice").html("¥"+(total_price - voucher_list[key].vt_price));
			$("#voucher_dis").html('<td class="t01">代金券优惠</td><td class="t02"></td><td class="t03">-¥'+voucher_list[key].vt_price+'</td>');
			$("#t-price").html("合计  ¥"+(total_price - voucher_list[key].vt_price));
			return;
		}
    }
	$("#totalPrice").html("¥"+total_price);
	$("#voucher_dis").html('');
	$("#t-price").html("合计  ¥"+total_price);
}

//下订单
function createOrder(){

    var receiver_name = $('#receiver_name').val();
    if(receiver_name == 0){
        alert("请先填写收货人！");
        return false;
    }

    var cellphone = $('#cellphone').val();
    if(cellphone == 0){
        alert("请先填写联系方式！");
        return false;
    }

    $("#orderForm").submit();
}
</script>
</body>
</html>